package com.google.code.bankagregator.adapter.bank.alpha;

import com.google.code.bankagregator.adapter.Adapter;
import com.google.code.bankagregator.adapter.bank.alpha.parser.credit.AlphaAutoCreditParser;
import com.google.code.bankagregator.adapter.bank.alpha.parser.credit.AlphaConsCreditParser;
import com.google.code.bankagregator.adapter.bank.alpha.parser.deposit.*;
import com.google.code.bankagregator.adapter.exception.AdapterConnectException;
import com.google.code.bankagregator.entities.Credit;
import com.google.code.bankagregator.entities.Deposit;
import com.google.code.bankagregator.vo.AdapterResult;
import com.google.code.bankagregator.vo.AdapterWarning;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: kirill
 * Date: 01.06.13
 * Time: 1:45
 * To change this template use File | Settings | File Templates.
 */
public class AdapterAlpha implements Adapter {
    @Override
    public AdapterResult getResult() {
        AdapterResult result = new AdapterResult();

        List<Credit> credits = new ArrayList<Credit>();
        List<Deposit> deposits = new ArrayList<Deposit>();
        List<AdapterWarning> warnings = new ArrayList<AdapterWarning>();

        List<Credit> creditList = null;
        List<Deposit> depositList = null;

        try {
            creditList = new AlphaConsCreditParser().getCredit();
            credits.addAll(creditList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            creditList = new AlphaAutoCreditParser().getAutoCreditFiftyPrep();
            credits.addAll(creditList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            creditList = new AlphaAutoCreditParser().getAutoCreditSixtyPrep();
            credits.addAll(creditList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            creditList = new AlphaAutoCreditParser().getAutoCreditTenPrep();
            credits.addAll(creditList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            creditList = new AlphaAutoCreditParser().getAutoCreditTwentyFivePrep();
            credits.addAll(creditList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }


        try {
            depositList = new AlphaDepTripleAdvantageParser().getUAHDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepTripleAdvantageParser().getUSDDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepTripleAdvantageParser().getEURDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepRantPlusParser().getUAHDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepRantPlusParser().getUSDDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepRantPlusParser().getEURDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepRantRefillParser().getUAHDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepRantRefillParser().getUSDDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepRantRefillParser().getEURDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepMegaProfitRefillParser().getUAHDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepMegaProfitRefillParser().getUSDDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepMegaProfitRefillParser().getEURDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepMegaProfitParser().getUAHDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepMegaProfitParser().getUSDDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepMegaProfitParser().getEURDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepSavingParser().getUAHDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepSavingParser().getUSDDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        try {
            depositList = new AlphaDepSavingParser().getEURDeposit();
            deposits.addAll(depositList);
        } catch (AdapterConnectException e) {
            warnings.add(new AdapterWarning(e.getMessage()));
        }
        result.setCredits(credits);
        result.setDeposits(deposits);
        result.setWarnings(warnings);

        return result;
    }

}
